package cn.qihua.service.impl;

import java.util.List;

import cn.qihua.dao.IBaseOrderDAO;

import cn.qihua.model.BaseOrder;
import cn.qihua.service.IOrderService;

public class OrderService implements IOrderService {
	private IBaseOrderDAO baseOrderDAO;
	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.baidu.service.impl.IBaseOrderService#findById(java.lang.Integer)
	 */
	/* (non-Javadoc)
	 * @see cn.qihua.service.impl.IBaseOrderService#findById(java.lang.Integer)
	 */


	public BaseOrder findById(Integer id) {
		return baseOrderDAO.findById(id);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.baidu.service.impl.IBaseOrderService#findAll()
	 */
	/* (non-Javadoc)
	 * @see cn.qihua.service.impl.IBaseOrderService#findAll()
	 */


	@SuppressWarnings("unchecked")
	public List<BaseOrder> findAll() {
		return baseOrderDAO.findAll();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.baidu.service.impl.IBaseOrderService#getTotal()
	 */
	/* (non-Javadoc)
	 * @see cn.qihua.service.impl.IBaseOrderService#getTotal()
	 */


	public Integer getTotal() {
		return baseOrderDAO.getTotal();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.baidu.service.impl.IBaseOrderService#findAll(int, int)
	 */
	/* (non-Javadoc)
	 * @see cn.qihua.service.impl.IBaseOrderService#findAll(int, int)
	 */


	public List<BaseOrder> findAll(int start, int limit) {
		return baseOrderDAO.findAll(start, limit);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.baidu.service.impl.IBaseOrderService#add(cn.baidu.model.BaseOrder)
	 */
	/* (non-Javadoc)
	 * @see cn.qihua.service.impl.IBaseOrderService#add(cn.qihua.model.BaseOrder)
	 */


	public Boolean add(BaseOrder transientInstance) {
		return baseOrderDAO.save(transientInstance);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.baidu.service.impl.IBaseOrderService#del(java.lang.Integer)
	 */
	/* (non-Javadoc)
	 * @see cn.qihua.service.impl.IBaseOrderService#del(java.lang.Integer)
	 */


	public boolean del(Integer id) {
		BaseOrder cst = baseOrderDAO.findById(id);
		if (cst != null) {
			baseOrderDAO.delete(cst);
			return true;
		} else {
			return false;
		}
	}

	public boolean edit(BaseOrder transientInstance) {
		return baseOrderDAO.update(transientInstance);
	}

	@SuppressWarnings("unchecked")
	public List<BaseOrder> findByProperty(String propertyName, Object value) {
		return baseOrderDAO.findByProperty(propertyName, value);
	}


	public List<BaseOrder> findByStatus(String status, int start, int limit) {
		return baseOrderDAO.findByStatus(status, start, limit);
	}

	/* (non-Javadoc)
	 * @see cn.qihua.service.impl.IBaseOrderService#findByStatus(java.lang.Integer)
	 */

	@SuppressWarnings("unchecked")
	public List<BaseOrder> findByStatus(String status) {
		return baseOrderDAO.findByStatus(status);
	}

	/* (non-Javadoc)
	 * @see cn.qihua.service.impl.IBaseOrderService#getTotalByProperty(java.lang.String, java.lang.Object)
	 */


	public Integer getTotalByProperty(String propertyName, Object value) {
		return baseOrderDAO.getTotalByProperty(propertyName, value);
	}

	public boolean changeStatus(int id, String status) {
		// TODO Auto-generated method stub
		return baseOrderDAO.changeStatus(id, status);
	}

	public void setBaseOrderDAO(IBaseOrderDAO baseOrderDAO) {
		this.baseOrderDAO = baseOrderDAO;
	}
	
}
